#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:
    bool canPlaceFlowers(vector<int>& flowerbed, int n) {
        /*
        if(flowerbed.size()==0){
            return 0>=n;
        }
        if(flowerbed.size()==1){
            return (flowerbed[0]==0&&1>=n)||(flowerbed[0]==1&&0>=n);
        }
        int sum=0;
        int zeros=0;
        
        int left=0;
        int right=flowerbed.size()-1;
        
        while(left<flowerbed.size()&&flowerbed[left]==0){
            left++;
        }
        //cout<<left<<endl;
        if(left==flowerbed.size()){
            return (left+1)/2>=n;
        }
        sum=sum+left/2;
        while(flowerbed[right]==0){
            right--;
        }
        sum=sum+(flowerbed.size()-1-right)/2;
        for(int i=left;i<right+1;i++){
            if(flowerbed[i]==0){
                zeros++;
            } else{
                sum=sum+(zeros-1)/2;
                zeros=0;
            }
        }
        //cout<<sum<<endl;
        return sum>=n;
        */
        flowerbed.insert(flowerbed.begin(),0);
        flowerbed.insert(flowerbed.end(),0);
        int counts=0;
        for(int i=1;i<flowerbed.size()-1;i++){
            if(flowerbed[i-1]==0&&flowerbed[i]==0&&flowerbed[i+1]==0){
                flowerbed[i]=1;
                counts++;
            }
        }
        return counts>=n;
    }
};


int main(){
    Solution s;
    vector<int> in{0,0};
    cout<<s.canPlaceFlowers(in,2)<<endl;
    return 0;
}